
package org.upt.dcda.db;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * The persistent class for the booktags database table.
 * 
 */
@Entity
@Table(name = "booktags")
@NamedQuery(name = BookTagEntity.VIEW_BOOK_TAGS, query = "SELECT booktagsm.tag FROM BookTagEntity booktagsm WHERE booktagsm.book.bookId = :bookId")
public class BookTagEntity implements Serializable
{

	private static final long	serialVersionUID	= 1L;

	public static final String	VIEW_BOOK_TAGS		= "view_book_tags";

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "booktag_id")
	private int					booktagId;

	@ManyToOne(cascade = CascadeType.REMOVE)
	@JoinColumn(name = "booktag_tag_id")
	private TagEntity			tag;

	@ManyToOne(cascade = CascadeType.REMOVE)
	@JoinColumn(name = "booktag_book_id")
	private BookEntity			book;

	public BookTagEntity()
	{
	}

	public int getBooktagId()
	{
		return this.booktagId;
	}

	public void setBooktagId(int booktagId)
	{
		this.booktagId = booktagId;
	}

	// bi-directional many-to-one association to TagEntity

	public TagEntity getTag()
	{
		return this.tag;
	}

	public void setTag(TagEntity tag)
	{
		this.tag = tag;
	}

	// bi-directional many-to-one association to BookEntity

	public BookEntity getBook()
	{
		return this.book;
	}

	public void setBook(BookEntity book)
	{
		this.book = book;
	}

}
